package dao;

import utils.JNDIUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class PersonDao {
    public void getPerson() {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try{
        conn = JNDIUtils.getConnection();
        String sql = "select * from person where id = ?";
        ps = conn.prepareStatement(sql);
        ps.setString(1, "1");
        rs = ps.executeQuery();
        while(rs.next()){
            System.out.println("person name is "+rs.getString("name"));
        }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JNDIUtils.close(rs,ps,conn);
        }
    }
}
